#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>

using namespace std;

const int maxn=100005;
const int maxm=5005;
const int maxnod=2000005;

int numbers[maxn],sequence[maxn],rt[maxn];
int ls[maxnod],rs[maxnod],sum[maxnod];
int cnt_nodes,dest;

inline int read(){
    char c;int r;bool f=0;
    for(c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=!f;
    for(r=0;c<='9'&&c>='0';c=getchar()) r=r*10+c-'0';
    if(f) return -r;
    else return r;
}

void inc(int &root,const int &old,const int &l,const int &r){
    root=++cnt_nodes;
    sum[root]=sum[old];
    if(l==r) sum[root]++;
    else{
        int mid=(l+r)>>1;
        ls[root]=ls[old];
        rs[root]=rs[old];
        if(dest<=mid) inc(ls[root],ls[old],l,mid);
        else inc(rs[root],rs[old],mid+1,r);
        sum[root]=sum[ls[root]]+sum[rs[root]];
    }
}

inline int query(int cur,int old,int l,int r,int k){
    while(l<r){
        int mid=(l+r)>>1;
        if(sum[ls[cur]]-sum[ls[old]]>=k){
            r=mid;
            cur=ls[cur];
            old=ls[old];
        }else{
            k-=sum[ls[cur]]-sum[ls[old]];
            l=mid+1;
            cur=rs[cur];
            old=rs[old];
        }
    }
    return l;
}

int main(){
    int n,m,cnt_numbers;

    n=read();m=read();
    for(int i=0;i<n;i++)
        sequence[i]=numbers[i]=read();
    sort(numbers,numbers+n);
    cnt_numbers=unique(numbers,numbers+n)-numbers;
    for(int i=0;i<n;i++) sequence[i]=lower_bound(numbers,numbers+cnt_numbers,sequence[i])-numbers+1;

    for(int i=0;i<n;i++) dest=sequence[i],inc(rt[i+1],rt[i],1,cnt_numbers);
    for(int i=0;i<m;i++){
        int l,r,k;
        l=read();r=read();k=read();
        printf("%d\n",numbers[query(rt[r],rt[l-1],1,cnt_numbers,k)-1]);
    }

    return 0;
}
